package day10;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionTest {
    public static void main(String[] args) {
        //c创建集合对象 子类对象指向父类引用
        //
        Collection<String> c1 = new ArrayList<>();
        Collection<String> c2 = new ArrayList<>();
        String s1 = "hello";
        String s2 = "world";
        c1.add(s1);
        c1.add(s2);
        System.out.println("c1:" +c1);
        String s3 = "你好";
        String s4 = "world";
        String s5= "ok";
        c2.add(s3);
        c2.add(s4);
        c2.add(s5);
        System.out.println("c2:" + c2);
        c1.addAll(c2);
        System.out.println("c1:" + c1);
        //判断是否包含指定元素 heiio是字符串常量
        boolean b1 = c1.contains("hello");
        //s6是一个对象 hello是存在堆区对象空间中的
        System.out.println("c1 contains hello? :" + b1);
        String s6 = new String("hello");
        b1 = c1.contains(s6);
        System.out.println("c1 contains s6-hello? :" + b1);
        //两个结果都是true 证明判断的结果都是
    }
}
